package com.hyt.application.api;

import com.hyt.application.api.request.NBCBEBankData;
import com.hyt.application.api.request.OutwardRemittanceQueryRequest;
import com.hyt.application.api.request.OutwardRemittanceRequest;
import com.hyt.application.api.response.CommonRemittanceResponse;
import com.hyt.application.api.response.CommonWebResponse;
import com.hyt.application.service.OutwardRemittanceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 汇款申请API
 *
 * @author 黄雨涛
 * date 20220614
 */

@RestController
@Slf4j
public class OutwardRemittanceApi {

    @Autowired
    OutwardRemittanceService service;

    /**
     * test
     * @return
     */
    @GetMapping("/hello")
    public String hello() {
        return "hello";
    }

    /**
     * 汇出汇款申请
     * @param outwardRemittanceRequest
     * @return
     */
    @PostMapping("/outward_remittance")
    public CommonWebResponse outwardRemittance(@RequestBody OutwardRemittanceRequest outwardRemittanceRequest) {
        CommonRemittanceResponse remittanceResponse = service.outwardRemittance(outwardRemittanceRequest);
        log.info("outward_remittance");
        return new CommonWebResponse().success().data(remittanceResponse);
    }

    /**
     * 汇出汇款查询
     * @param outwardRemittanceQueryRequest
     * @return
     */
    @PostMapping("/outward_remittance_query")
    public CommonWebResponse outwardRemittanceQuery(@RequestBody OutwardRemittanceQueryRequest outwardRemittanceQueryRequest) {
        CommonRemittanceResponse queryResponse = service.outwardRemittanceQuery(outwardRemittanceQueryRequest);
        log.info("outward_remittance_query");
        return new CommonWebResponse().success().data(queryResponse);
    }


    /**
     * 汇出汇款申请
     * @param nBCBEBankData
     * @return
     */
    @PostMapping(value = "/outward_remittance_v2",produces = MediaType.APPLICATION_XML_VALUE
            ,consumes = MediaType.APPLICATION_XML_VALUE)
    public Object outwardRemittanceV2(@RequestBody NBCBEBankData nBCBEBankData) {
        System.out.println(nBCBEBankData);
       return nBCBEBankData;
    }

}
